<?php

namespace IDock\Insurance\ACIC\Request;

use Exception;
use IDock\Insurance\ACIC\Response\ProposalRecallResponse;
use IDock\Visitor\ProposalRecallVisitor;

class ProposalRecallRequest extends AllACICRequest
{
    protected $code = 'V21';

    protected $response = ProposalRecallResponse::class;

    protected $urlTip = '投保单撤回';

    /**
     * @var ProposalRecallVisitor $visitor
     */
    protected $visitor;

    /**
     * @return array
     * @throws Exception
     */
    public function generate(): array
    {

        $list = [];

        if ($this->visitor->biInquiryNo) {
            $list[] =[
                'AppNo' => $this->visitor->biInquiryNo,
                'Reason' => $this->visitor->reason
            ];
        }
        if ($this->visitor->ciInquiryNo) {
            $list[] =[
                'AppNo' => $this->visitor->ciInquiryNo,
                'Reason' => $this->visitor->reason
            ];
        }

        return [
            'OrgCode' => $this->visitor->argc['OrgCode'] ?? '',
            'CancelInfos' => [
                'CancelInfo' =>$list,
            ],
        ];
    }
}